﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
namespace Powershell_ML
{
    class Configuration : Exchange_Information
    {
        public Configuration()
        {
            try
            {
                int day = 0;
                int hours = 0;
                int min = 0;
                int second = 0;

                this.ServerMonitor = new List<string>();
                Hashtable section = (Hashtable)ConfigurationManager.GetSection("MonGroupe/MaSectionDeux");
                Hashtable Collection_Time = (Hashtable)ConfigurationManager.GetSection("MonGroupe/Collection_Time");
                foreach (DictionaryEntry d in section)
                {
                    this.ServerMonitor.Add(d.Value.ToString());
                    Console.WriteLine("Configuration Loaded for : {0}", d.Value);
                }
                foreach (DictionaryEntry d in Collection_Time)
                {
                    if (d.Key == "day") { day = int.Parse(d.Value.ToString()); }
                    if (d.Key == "hours") { hours =  int.Parse(d.Value.ToString()); }
                    if (d.Key == "minutes") { min =  int.Parse(d.Value.ToString()); }
                    if (d.Key == "secondes") { second =  int.Parse(d.Value.ToString()); }
                }
                this.CollectFrequency = new TimeSpan(day, hours, min, second);
            }
            catch (Exception) { }
        }
        public TimeSpan CollectFrequency
        {
            get;set;
        }
        public List<string> ServerMonitor
        {
            get;set;
        }
        public string OrganizationName
        {
            get;
            set;
        }
        public string ATTR1
        {
            get;
            set;
        }
        public string ConfigurationName
        {
            get;
            set;
        }

    }

}
